#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;

inline char getc() {
    static char buf[1 << 18], *fs, *ft;
    return (fs == ft && (ft = (fs = buf) + fread(buf, 1, 1 << 18, stdin)), fs == ft) ? EOF : *fs++;
}

inline int gn() {
    int k = 0, f = 1;
    char c = getc();
    for (; !isdigit(c); c = getc()) if (c == '-') f = -1;
    for (; isdigit(c); c = getc()) k = k * 10 + (c ^ 0x30);
    return k * f;
}

int n, k, s[10000023];

int qsort(int l, int r) {
    if(l == r) return s[l];
    register int tmp, i = l, j = r, M = s[l + rand() % (r - l + 1)];
    do{
        while(s[i] < M) ++i;
        while(s[j] > M) --j;
        if(i <= j) {
            tmp = s[i];
            s[i] = s[j];
            s[j] = tmp;
            ++i, --j;
        }
    }while(i <= j);
    if(k <= j) return qsort(l, j);
    if(i <= k) return qsort(i, r);
    return tmp;
}

int main() {
#ifndef LOCAL
    freopen("find_k.in", "r", stdin);
    freopen("find_k.out", "w", stdout);
#endif
    n = gn(), k = gn() - 1;
    srand(n);
    for (int i = 0; i < n; i++)
        s[i] = gn();
    cout << qsort(0, n - 1);
}